home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performPaintEffectsToPoly.me < prev    next >
Encoding:
Text File  |  2003-07-17  |  9.9 KB  |  414 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //  Alias|Wavefront Script File
  18. //  MODIFY THIS AT YOUR OWN RISK
  19. //
  20. //  Creation Date:  2002 
  21. //  Author:         dbrins
  22. //
  23. //  Description:
  24. //        Option box for paint effects to poly 
  25. //
  26.  
  27. //
  28. //  Procedure Name:
  29. //      setOptionVars
  30. //
  31. //  Description:
  32. //        Initialize the option values.
  33. //
  34. //  Input Arguments:
  35. //        Whether to set the options to default values.
  36. //
  37. //  Return Value:
  38. //      None.
  39. //
  40. //  Note:
  41. //     Commented out Type option for this rev
  42. //
  43. proc setOptionVars(int $forceFactorySettings)
  44. {
  45.  
  46.     //   Vertex Color Mode    
  47.     //    
  48.     if ($forceFactorySettings ||
  49.         !`optionVar -exists pfxToPolyVertColorMode`) {
  50.         optionVar -intValue pfxToPolyVertColorMode 0; 
  51.     }
  52.  
  53.  
  54.     //    Quad Output    
  55.     //    
  56.     if ($forceFactorySettings ||
  57.         !`optionVar -exists pfxToPolyQuadOutput`) {
  58.         optionVar -intValue pfxToPolyQuadOutput 0;
  59.     }
  60.  
  61.     //    HideStrokes
  62.     //    
  63.     if ($forceFactorySettings ||
  64.         !`optionVar -exists pfxToPolyHideStrokes`) {
  65.         optionVar -intValue pfxToPolyHideStrokes 1;
  66.     }
  67.  
  68.     //    Poly Limit
  69.     //    
  70.     if ($forceFactorySettings ||
  71.         !`optionVar -exists pfxToPolyLimit`) {
  72.         optionVar -intValue pfxToPolyLimit 100000;
  73.     }
  74.  
  75. }
  76.  
  77.  
  78. //
  79. //  Procedure Name:
  80. //      paintEffectsToPolySetup
  81. //
  82. //  Description:
  83. //        Update the state of the option box UI to reflect the option values.
  84. //
  85. //  Input Arguments:
  86. //      parent               - Top level parent layout of the option box UI.
  87. //                             Required so that UI object names can be 
  88. //                             successfully resolved.
  89. //
  90. //    forceFactorySettings - Whether the option values should be set to
  91. //                             default values.
  92. //
  93. //  Return Value:
  94. //      None.
  95. //
  96. global proc paintEffectsToPolySetup(string $parent, int $forceFactorySettings)
  97. {
  98.     int $method;
  99.  
  100.     //    Retrieve the option settings
  101.     //
  102.     setOptionVars($forceFactorySettings);
  103.  
  104.     setParent $parent;
  105.  
  106.     //    Query the optionVar's and set the values into the controls.
  107.  
  108.     // Vertex Color Mode 
  109.     int $mode = `optionVar -query pfxToPolyVertColorMode`;
  110.     radioButtonGrp -edit -select ($mode+1) pfxToPolyVertColorMode;
  111.  
  112.     // Quad Output 
  113.     //
  114.     int $quadOutput = `optionVar -query pfxToPolyQuadOutput`;
  115.     checkBoxGrp -edit -v1 $quadOutput pfxToPolyQuadOutputBox;
  116.  
  117.     // Hide Strokes
  118.     //
  119.     int $hideStrokes = `optionVar -query pfxToPolyHideStrokes`;
  120.     checkBoxGrp -edit -v1 $hideStrokes pfxToPolyHideStrokesBox;
  121.  
  122.     // Poly Limit
  123.     //
  124.     int $polyLimit = `optionVar -query pfxToPolyLimit`;
  125.     intSliderGrp -edit -v $polyLimit pfxToPolyLimitSlider;
  126. }
  127.  
  128. //
  129. //  Procedure Name:
  130. //      paintEffectsToPolyCallback
  131. //
  132. //  Description:
  133. //        Update the option values with the current state of the option box UI.
  134. //
  135. //  Input Arguments:
  136. //      parent - Top level parent layout of the option box UI.  Required so
  137. //               that UI object names can be successfully resolved.
  138. //
  139. //    doIt   - Whether the command should execute.
  140. //
  141. //  Return Value:
  142. //      None.
  143. //
  144. global proc paintEffectsToPolyCallback(string $parent, int $doIt)
  145. {
  146.     setParent $parent;
  147.  
  148.     //    Set the optionVar's from the control values, and then
  149.     //    perform the command.
  150.  
  151.     //    Vertex Color Mode    
  152.     //    
  153.     int $val = `radioButtonGrp -query -select pfxToPolyVertColorMode`;
  154.     optionVar -intValue pfxToPolyVertColorMode ($val-1);
  155.  
  156.     //    Quad Output
  157.     //
  158.     optionVar -intValue pfxToPolyQuadOutput
  159.         `checkBoxGrp -q -v1 pfxToPolyQuadOutputBox`;
  160.  
  161.     //    Hide Strokes
  162.     //
  163.     optionVar -intValue pfxToPolyHideStrokes
  164.         `checkBoxGrp -q -v1 pfxToPolyHideStrokesBox`;
  165.  
  166.     //    Poly Limit
  167.     //
  168.     optionVar -intValue pfxToPolyLimit
  169.         `intSliderGrp -q -v pfxToPolyLimitSlider`;
  170.  
  171.     if ($doIt) {
  172.         performPaintEffectsToPoly 0; 
  173.         addToRecentCommandQueue "performPaintEffectsToPoly 0" "PaintEffectsToPoly";
  174.     }
  175. }
  176.  
  177. //
  178. //  Procedure Name:
  179. //      paintEffectsToPolyOptions
  180. //
  181. //  Description:
  182. //        Construct the option box UI.  Involves accessing the standard option
  183. //        box and customizing the UI accordingly.
  184. //
  185. //  Input Arguments:
  186. //      None.
  187. //
  188. //  Return Value:
  189. //      None.
  190. //
  191. proc paintEffectsToPolyOptions()
  192. {
  193.     //    Name of the command for this option box.
  194.     //
  195.     string $commandName = "paintEffectsToPoly";
  196.  
  197.     //    Build the option box actions.
  198.     //
  199.     string $callback = ($commandName + "Callback");
  200.     string $setup = ($commandName + "Setup");
  201.  
  202.     //    STEP 1:  Get the option box.
  203.     //    ============================
  204.     //
  205.     string $layout = getOptionBox();
  206.     setParent $layout;
  207.     
  208.     //    STEP 2:  Pass the command name to the option box.
  209.     //    =================================================
  210.     //
  211.     setOptionBoxCommandName($commandName);
  212.     
  213.     //    STEP 3:  Activate the default UI template.
  214.     //    ==========================================
  215.     //
  216.     setUITemplate -pushTemplate DefaultTemplate;
  217.  
  218.     //    STEP 4: Create option box contents.
  219.     //    ===================================
  220.     //    
  221.     
  222.     //    Turn on the wait cursor.
  223.     //
  224.     waitCursor -state 1;
  225.  
  226.     tabLayout -tabsVisible 0 -scrollable 1;
  227.     
  228.     string $parent = `columnLayout -adjustableColumn 1`;
  229.     
  230.      //    Vertex Color Mode    
  231.      //    
  232.     string $radioBtnGrp1 =`radioButtonGrp
  233.         -nrb 3
  234.         -label "Vertex Color Mode"
  235.         -l1 "None"
  236.         -l2 "Color"
  237.         -l3 "Illuminated"
  238.         pfxToPolyVertColorMode`;
  239.  
  240.     checkBoxGrp -label "Quad Output" -l1 ""
  241.         pfxToPolyQuadOutputBox;
  242.  
  243.     checkBoxGrp -label "Hide Strokes" -l1 ""
  244.         pfxToPolyHideStrokesBox;
  245.  
  246.     intSliderGrp
  247.         -label "Poly Limit"
  248.         -field 1
  249.         -min 0
  250.         -max 100000
  251.         -fieldMinValue 0
  252.         -fieldMaxValue 1000000
  253.         -ann "Limit number of faces per output mesh: a value of 0 means no limit."
  254.         pfxToPolyLimitSlider;
  255.  
  256.     //    Turn off the wait cursor.
  257.     //
  258.     waitCursor -state 0;
  259.     
  260.     //    Step 5: Deactivate the default UI template.
  261.     //    ===========================================
  262.     //
  263.     setUITemplate -popTemplate;
  264.  
  265.     //    Step 6: Customize the buttons.  
  266.     //    ==============================
  267.     //
  268.  
  269.     //    'Apply' button.
  270.     //
  271.     string $applyBtn = getOptionBoxApplyBtn();
  272.     button -edit -l "Convert"
  273.         -command ($callback + " " + $parent + " " + 1)
  274.         $applyBtn;
  275.  
  276.     //    'Save' button.
  277.     //
  278.     string $saveBtn = getOptionBoxSaveBtn();
  279.     button -edit 
  280.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  281.         $saveBtn;
  282.  
  283.     //    'Reset' button.
  284.     //
  285.     string $resetBtn = getOptionBoxResetBtn();
  286.     button -edit 
  287.         -command ($setup + " " + $parent + " " + 1)
  288.         $resetBtn;
  289.  
  290.     //    Step 7: Set the option box title.
  291.     //    =================================
  292.     //
  293.     setOptionBoxTitle("Paint Effects To Polygons Options");
  294.  
  295.     //    Step 8: Customize the 'Help' menu item text.
  296.     //    ============================================
  297.     //
  298.     setOptionBoxHelpTag( "PaintEffectsToPoly" );
  299.  
  300.     //    Step 9: Set the current values of the option box.
  301.     //    =================================================
  302.     //
  303.     eval (($setup + " " + $parent + " " + 0));    
  304.     
  305.     //    Step 10: Show the option box.
  306.     //    =============================
  307.     //
  308.     showOptionBox();
  309. }
  310.  
  311. //
  312. //  Procedure Name:
  313. //      paintEffectsToPolyHelp
  314. //
  315. //  Description:
  316. //        Return a short description about this command.
  317. //
  318. //  Input Arguments:
  319. //      None.
  320. //
  321. //  Return Value:
  322. //      string.
  323. //
  324. proc string paintEffectsToPolyHelp()
  325. {
  326.     return 
  327.     "  Command: doPaintEffectsToPoly- tessellate paint effects strokes into polygons.\n" +
  328.     "Selection: Paint Effects strokes.";
  329. }
  330.  
  331. //
  332. //  Procedure Name:
  333. //      assembleCmd
  334. //
  335. //  Description:
  336. //        Construct the command that will apply the option box values.
  337. //
  338. //  Input Arguments:
  339. //      None.
  340. //
  341. proc string assembleCmd()
  342. {
  343.     setOptionVars(false);
  344.  
  345.     int $vertColorMode = `optionVar -query pfxToPolyVertColorMode`;
  346.     int $quadOutput = `optionVar -query pfxToPolyQuadOutput`;
  347.     int $hideStrokes = `optionVar -query pfxToPolyHideStrokes`;
  348.     int $polyLimit = `optionVar -query pfxToPolyLimit`;
  349.     int $doHistory = `constructionHistory -q -tgl`;
  350.  
  351.         string $cmd = ("doPaintEffectsToPoly( "
  352.             +$doHistory
  353.             +","+$vertColorMode
  354.             +","+$quadOutput
  355.             +","+$hideStrokes
  356.             +","+$polyLimit+")");
  357.     return $cmd;
  358. }
  359.  
  360. //
  361. //  Procedure Name:
  362. //      performPaintEffectsToPoly
  363. //
  364. //  Description:
  365. //        Perform the performPaintEffectsToPoly command using the corresponding 
  366. //        option values.  This procedure will also show the option box
  367. //        window if necessary as well as construct the command string
  368. //        that will invoke the performPaintEffectsToPoly command with the current
  369. //        option box values.
  370. //
  371. //  Input Arguments:
  372. //      0 - Execute the command.
  373. //      1 - Show the option box dialog.
  374. //      2 - Return the command.
  375. //
  376. global proc string performPaintEffectsToPoly(int $action)
  377. {
  378.     string $cmd = "";
  379.     switch ($action) {
  380.  
  381.         //    Execute the command.
  382.         //
  383.         case 0:
  384.             //    Get the command.
  385.             //
  386.             $cmd = `assembleCmd`;
  387.  
  388.             //    Execute the command with the option settings.
  389.             //
  390.             // TODO change this to eval and have doPaintEffectsToPoly call
  391.             // a second routine with evalEcho, so that this command is echoed
  392.             // when returned (case 2 below )
  393.             evalEcho($cmd);
  394.  
  395.             break;
  396.  
  397.         //    Show the option box.
  398.         //
  399.         case 1:
  400.             paintEffectsToPolyOptions;
  401.             break;
  402.  
  403.         //    Return the command string.
  404.         //
  405.         case 2:
  406.             //    Get the command.
  407.             //
  408.             $cmd = `assembleCmd`;
  409.             break;
  410.     }
  411.     return $cmd;
  412. }
  413.  
  414.